package com.game.ammo {
	import com.game.data.Data;
	import com.game.units.Enemy;
	import com.game.utils.TowerType;
	
	import flash.filters.BlurFilter;
	import flash.filters.GlowFilter;
	import flash.geom.Point;

	public class Fire extends Ammo {
		private var position:Number = 0;
		private var t:Number = 0;
		private var flameSize:Number = 10;
	//	private var span:Point
		public function Fire(bulX:Number, bulY:Number, ang:Number, destination:Number, type:TowerType,upgrades:int,suggestiveDistance:int) {
			super(bulX, bulY, ang, destination, type,upgrades,suggestiveDistance);
		}
		override public function isHit(p3:Enemy):Boolean {
			if (this.pointToLineDistance(p3) < p3.size/2 + flameSize / 2) {
				return true;
			}
			return false;
		}
		
		override protected function initialSet():void {
			ammoSpeed = (Math.PI / 2) / 40;
			_damage=(upgrades+1)*2;
			p1.x=-(Data.STEP/2) * Math.cos(_angle);
			p1.y=-(Data.STEP/2) * Math.sin(_angle);
			//
			_rect.width = 200;
			_rect.height = 200;
			var ang:Number = (_angle * 180 / Math.PI) + 180;
			ang = ang < 0 ? 360 + ang : ang;
			_rect.x = Math.round(ang / 15) * 200;
			this._point.x = p1.x + x - 100;
			this._point.y = p1.y + y - 100;
		}
		override public function move():void {
			if (position > Math.PI / 2) {
				readyForRemoval = true;
			}
			position += this.ammoSpeed;
			
			var rad:Number = Math.min(destination * 2 * Math.sin(position), destination);
			_rect.y = int(10*(rad/destination)) * 200;
		}
	}
}